package com.web.surf.sample.eshop.faces.navigation;

import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import com.web.surf.sample.eshop.faces.interfaces.IRedirect;
import com.web.surf.sample.eshop.utils.FacesUtil;

/**
 * Navigation object for lists of categories and subcategories
 * @author LukyanyukDV
 * @author SavenkoNV
 */
public class RedirectNavigator implements IRedirect {

	private final String GOODS_OUTCOME = "goodsList";
	private final String SUBCATEGORIES_OUTCOME = "subcategoriesList";
	private final String FEATURES_OUTCOME = "featuresList";
	private final String BASKET_OUTCOME = "basket";
	private final String ORDER_OUTCOME = "order";
	private final String INDEX_OUTCOME = "index";

	public void processSelectedElement(ActionEvent ae) {
		FacesContext context = FacesContext.getCurrentInstance();
		Map<String, String> params = context.getExternalContext()
				.getRequestParameterMap();
		String set = params.get(IRedirect.REDIRECT_PARAM);
		FacesUtil.setSessionMapValue(IRedirect.REDIRECT_LINK, set);
	}

	public String getGoodsOutcome() {
		return GOODS_OUTCOME;
	}
	
	public String getIndexOutcome() {
		return INDEX_OUTCOME;
	}

	public String getSubcategoriesOutcome() {
		return SUBCATEGORIES_OUTCOME;
	}

	public String getFeaturesOutcome() {
		return FEATURES_OUTCOME;
	}

	public String getBasketOutcome() {
		return BASKET_OUTCOME;
	}

	public String getOrderOutcome() {
		return ORDER_OUTCOME;
	}
}